<!DOCTYPE html>
<head>
  <style>
    iframe {
      width: 200px;
      height: 300px;
    }
  </style>
  <script>
    addEventListener('load', function() {
      var source = '<!DOCTYPE html><body><div style="width:50vw;height:50vw;background-color:black"></div></body>';
      var iframe = document.createElement('iframe');
      iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(source);
      document.body.appendChild(iframe);
    });
  </script>
</head>
<body>
</body>

